/**
 * Created by wujo5 on 1/19/2018.
 */
var express = require('express');
var testCasesCtrl = require('../controller/testCasesController');
var testcaseRelationshipCtrl = require('../controller/testcaseRelationshipController');
var router = express.Router();


router.put('/edit',function(req,res){
  testCasesCtrl.updateTestCase(req.body.params,function(data){
    res.send(data);
  },function (err) {
    res.send(err);
  })
});

router.post('/add',function(req,res){
  testCasesCtrl.addTestCase(req.body.params,function(data){
    res.send(data);
  },function(err){
    res.send(err);
  });

});

router.delete('/remove/:testCaseId',function(req,res){
  testCasesCtrl.removeTestCase(req.params,function(data){
    res.send(data);
  },function (err) {
    res.send(err);
  })
});

router.delete('/batchremove/:testCaseIds',function (req,res) {
  testCasesCtrl.batchRemoveTestCase(req.params,function(data){
    res.send(data);
  },function (err) {
    res.send(err);
  })
})

router.get('/FilterTestCaseList/:tags/:page/:pageSize',function(req,res){
  testCasesCtrl.getTestCasePageList(req.params,function(data){
    res.send(data);
  },function(err){
    res.send(err);
  })
});
router.get('/TestCaseList/:page/:pageSize',function(req,res){
  testCasesCtrl.getTestCasePageList(req.params,function(data){
    res.send(data);
  },function(err){
    res.send(err);
  })
});
// router.get('/TestCaseList/:page/:pageSize',testCasesCtrl.getTestCasePageList);
router.get('/TestCaseList',function(req,res){
  testCasesCtrl.getAll(function(data){
    res.send(data);
  },function(err){
    res.send(err);
  })
});
router.get('/allReadyTestCaseList',function(req,res){
    testCasesCtrl.getAllReadyTestCaseList(function(data){
        res.send(data);
    },function(err){
        res.send(err);
    })
});
router.get('/tagList',function(req,res){
    testCasesCtrl.getTagList(function(data){
      res.send(data);
    },function (err) {
      res.send(err);
    })
})

router.get('/name/:testCaseName',function(req,res){
   testCasesCtrl.checkTestCaseName(req.params,function(data){
     res.send(data);
   },function(err){
     res.send(err);
   })
});

router.post('/registerTestCase',function(req,res){
  testCasesCtrl.registerTestCase(req.body,function(data){
    res.send(data);
  },function(err){
    res.send(err);
  });
});

router.post('/registerTestSuit',function(req,res){
  testCasesCtrl.registerTestSuit(req.body,function(data){
    res.send(data);
  },function(err){
    res.send(err);
  });
});

router.post('/register/updateStatusById',function(req,res){
    testCasesCtrl.updateRegisterationStatusById(req.body,function(data){
        res.send(data);
    },function(err){
        res.send(err);
    });
});
router.get('/getLightWeightTestCaseList',testCasesCtrl.getLightWeightTestCaseList);
router.get('/getByName/:name', testCasesCtrl.getByName);
router.post('/getLWmapping', testCasesCtrl.getLWmapping);
router.post('/getSoapmapping', testCasesCtrl.getSoapmapping);
router.get('/getByTestCaseId/:testcaseId', testCasesCtrl.getByTestCaseId);
router.get('/getRegisterTestCase', testCasesCtrl.getRegisterTestCase);
router.get('/getTestSuit/status/:status', testCasesCtrl.getTestSuitByStatus);
router.post('/testSuit/update', testCasesCtrl.updateTestSuitStatus);
router.post('/testSuits/update', testCasesCtrl.updateTestSuitsStatus);
router.get('/getTestcaseByTestsuitId/:testsuitId', testCasesCtrl.getTestcaseRegByTestsuitId);
router.post('/register/updateByTSIds', testCasesCtrl.updateTestCaseRegByTestSuitIds);
router.get('/getDependencyTestcase/:testCaseId',testcaseRelationshipCtrl.getDependencyTestcase);
router.get('/register/status/:status', testCasesCtrl.getRegisterTestCaseBystatus);
router.post('/register/updateByIds',testCasesCtrl.updateRegistrationByIds);
router.post('/register/getByStatusAndLteTime', testCasesCtrl.fetchRegistrationByStatusAndLteDate);
router.post('/register/updateRegistrationWithExpectedDate',testCasesCtrl.updateRegistrationWithExpectedDate);
router.get('/register/getRegistrationsByTestSuitIdAndStatus/:testSuitId',testCasesCtrl.getRegistrationsByTestSuitIdAndStatus);
router.get('/register/getReplacedBizKeyTestCase/:testCaseId/:prepareFor',testCasesCtrl.getReplacedBizKeyTestCase);
router.post('/register/updateByStatusAndTestSuitId', testCasesCtrl.updateByStatusAndTestSuitId);
router.get('/getPrepareForByTestSuitId/:testSuitId' ,testCasesCtrl.getPrepareForByTestSuitId);
router.post('/updateTestCaseToReady', testCasesCtrl.updateTestCaseToReady);
router.get('/getAllDependencyBizKeysByTestcaseIds/:testcaseIds', testCasesCtrl.getAllDependencyBizKeysByTestcaseIds);

module.exports = router;
